//@author A0105730U
#include "Parser_Location.h"


Parser_Location::Parser_Location(void)
{
}


Parser_Location::~Parser_Location(void)
{
}


std::string Parser_Location::clear_Space_Punctuation(std::string s){
	std::size_t pos1 = s.find_first_not_of(NOT_FOUND_STRING_LOCATION);
	std::size_t pos2 = s.find_last_not_of(NOT_FOUND_STRING_LOCATION);

	if(pos1 == std::string::npos){
		return QUOTE_LOCATION;
	}

	return s.substr(pos1, pos2-pos1+1);
}


std::string Parser_Location::check(std::string input, std::string& inputNoLocation){
	inputNoLocation = input;

	std::size_t stPos = input.rfind(LOCATION_INDICATOR_LOCATION);
	if(stPos == std::string::npos){
		return QUOTE_LOCATION;
	}

	std::size_t edPos = input.find_first_of(']', stPos);
	if(edPos == std::string::npos){
		return FORMAT_ERROR_LOCATION;                              //format error
	}

	std::string prefix = input.substr(0,stPos);
	std::string suffix = input.substr(edPos+1,input.size()-edPos-1);
	inputNoLocation = prefix + QUOTE_BLANK_LOCATION + suffix;
	return input.substr(stPos+2, edPos-stPos-2);
}

		
		
